
<div class="pageContent">
	<form method="post" action="index.php?c=Goods&a=index" class="pageForm" onsubmit="return navTabSearch(this);">
		<div class="pageFormContent" layoutH="58">


			<div class="unit">
                <label>商品关键词：</label>
                <input type="text" name="keywords"/>
				<span class="inputInfo">关键字或全称</span>
			</div>

			<div class="unit">
                <label>日期区间-开始：</label>
                <input type="text" name="star" class="date" dateFmt="yyyy-MM-dd HH:mm:ss" readonly="true"/>
				<span class="inputInfo">输入开始时间</span>
			</div>

			<div class="unit">
                <label>日期区间-结束：</label>
                <input type="text" name="end" class="date" dateFmt="yyyy-MM-dd HH:mm:ss" readonly="true"/>
				<span class="inputInfo">输入结束时间</span>
			</div>

			<!-- <div class="divider">divider</div> -->
			<div class="unit">
<!-- 				<label>商家名称：</label>
				<select name="shopid">
						<option value="">请选择</option>
					<foreach name="shop" item="shop">
						<option value="{$shop.shopid}">{$shop.name}</option>
					</foreach>
				</select> -->
                <label>商家关键词：</label>
                <input type="text" name="shop_name"/>
				<span class="inputInfo">关键字或全称</span>
			</div>

			<div class="unit">
				<label>市场名称：</label>
				<select name="city">
						<option value="">请选择</option>
					<foreach name="city" item="city">
						<option value="{$city.id}">{$city.name}</option>
					</foreach>
				</select>
			</div>

			<div class="unit">
				<label>商品分类：</label>
				<select name="categroy" onchange="zifenleis(this.value)">
						<option value="">请选择</option>
					<foreach name="categroy" item="categroy">
						<option value="{$categroy.cateid}" >{$categroy.name}</option>
					</foreach>
				</select>
			</div>

			<div class="unit">
				<label>商品子分类：</label>
				<select name="zifenlei" id="zifenlei">
						<option value="">请选择</option>
					<foreach name="zifenlei" item="zifenlei">
						<option value="{$zifenlei.id}" >{$zifenlei.name}</option>
					</foreach>
				</select>
			</div>

			<div class="unit">
				<label>拼团专区：</label>
				<select name="activity" onchange="fields(this.value)">
						<option value="">请选择</option>
						<option value="4">猜你喜欢</option>
						<option value="5">新人专享</option>
						<option value="6">扫货</option>
						<option value="7">限时折扣</option>
						<option value="8">为您挑货</option>
						<!-- <option value="9">排行榜</option> -->
						<!-- <option value="10">天天上新</option> -->
					<foreach name="buygroup" item="buygroup">
						<option value="{$buygroup.buygroup_id}">{$buygroup.name}</option>
					</foreach>
				</select>
				<input type="hidden" name="field" id="field" value="">
			</div>

		</div>
		<div class="formBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">开始检索</button></div></div></li>
				<li><div class="button"><div class="buttonContent"><button type="reset">清空重输</button></div></div></li>
			</ul>
		</div>
	</form>
</div>
<script type="text/javascript">
	/**
	 * [获取商家子分类数据]
	 * @Author   Axing
	 * @DateTime 2017-08-21
	 * @param    {[type]}   cateid [商家分类id]
	 * @return   {[array]}         [子分类数据]
	 */
	function zifenleis(cateid) {
        $.ajax({
          type:"POST",
          async: false,
          url: "index.php?c=Goods&a=s_zifenlei",
          data: {"cateid":cateid},
          dataType:'json',
          success:function(data){
          	console.log(data);
                var html = '';
                	html += "<option value=''>全部</option>";
                for(i=0;i<data.length;i++) {
                    html += "<option value =" + data[i]['id'] + ">"+ data[i]['name'] +"</option>";
                }
                $('#zifenlei').html(html);
            }
        });
	}

	function fields(type) {
		// var fields = 'buygroup_id';
		var num = parseInt(type);
		switch(num) {
			case 1:
			  var fields = 'buygroup_id';
			  break;
			case 2:
			  var fields = 'buygroup_id';
			  break;
			case 3:
			  var fields = 'buygroup_id';
			  break;
			case 4:
			  var fields = 'xihuan';
			  break;
			case 5:
			  var fields = 'tejia';
			  break;
			case 6:
			  var fields = 'act_saohuo';
			  break;
			case 7:
			  var fields = 'act_xianshizhekou';
			  break;
			case 8:
			  var fields = 'act_nixiangyaode';
			  break;
		}
		$("#field").val(fields); //OK
	}
</script>